# class Queue():
#     def __init__(self,size):
#         self.size = size  #队长
#         self.queue = []
#         """Constructor for Queue"""
#
#     #入列
#     def onadd(self,m):
#         # 队满
#         if self.isFull():
#             return -1
#         self.queue.append(m)
#     #出列
#     def outQueue(self):
#         if self.isFull():
#             return -1
#         queue_ = self.queue[0]
#         self.queue.remove(queue_)
#         return queue_
#
#     #添加
#     def input(self,n,m):
#         self.queue[n] = m
#     def remove(self,n,m):
#         if self.isEmpty():
#             return -1
#         self.queue[n] = m
#     #拿取队列长度
#     def getLength(self):
#         return len(self.queue)
#     # 队满
#     def isFull(self):
#         if self.size == self.getLength():
#             return True
#         return False
#     #队空
#     def isEmpty(self):
#         if self.getLength() == 0:
#             return True
#         return False
#     def __str__(self):
#         return "queue"+str(self.queue)
# if __name__ == '__main__':
#     queue_list = Queue(4)
#     for i in range(4):
#         queue_list.onadd(4)
#         print(i)
#     queue_list.input(2,3)
#     queue_list.outQueue()
#     print("queue_list",queue_list)
import threading
from queue import Queue

def work(data,q):
    # 放入数据前进行的操作
    for i in range(len(data)):
        data[i] = data[i]**3
    q.put(data)
def queue():
    q = Queue()
#    存放多个线程
    Threadings = []
    data = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]
    # 启动线程
    for i in range(len(data)):
        # 通过线程调用方法和传递参数
        t = threading.Thread(target=work,args=(data[i],q))
        t.start()
        Threadings.append(t)
    # 多线执行操作
    for thread in Threadings:
        thread.join()
    # 存放取出结果集
    results = []
    for i in range(len(data)):
        results.append(q.get())
    print(results)
queue()
